<link rel="stylesheet" href="assets/common/plugins/umeditor/themes/default/css/umeditor.css">
<div class="row">
    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
        <div class="widget am-cf">
            <form id="my-form" class="am-form tpl-form-line-form" method="post">
                <div class="widget-body">
                    <fieldset>
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">商户信息</div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">法人姓名</label>
                            <div class="am-u-sm-9 am-u-end">
                                <input type="text" class="tpl-form-input" name="agent[realname]" value="<?= $model['realname'];?>"
                                       required>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">法人电话</label>
                            <div class="am-u-sm-9 am-u-end">
                                <input type="text" class="tpl-form-input" name="agent[company_tel]" value="<?= $model['faren_num'];?>"
                                       required>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">法人身份证号码</label>
                            <div class="am-u-sm-9 am-u-end">
                                <input type="text" class="tpl-form-input" name="agent[id_num]" value="<?= $model['id_num'];?>"
                                       required>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">身份证正面照片 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                                <div class="file-item">
                                                    <a href="<?= getImage($model['id_img_face_id']) ?>"
                                                       title="点击查看大图" target="_blank">
                                                        <img src="<?= getImage($model['id_img_face_id']) ?>">
                                                    </a>

                                                </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">身份证背面照片 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                                <div class="file-item">
                                                    <a href="<?= getImage($model['id_img_back_id']) ?>"
                                                       title="点击查看大图" target="_blank">
                                                        <img src="<?= getImage($model['id_img_back_id']) ?>">
                                                    </a>
                                                </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">店铺名称</label>
                            <div class="am-u-sm-9 am-u-end">
                                <input type="text" class="tpl-form-input" name="agent[shop_name]" value="<?= $model['shop']['shop_name'];?>"
                                       required>
                            </div>
                        </div>
<!--                        <div class="am-form-group am-padding-top">-->
<!--                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 门店区域 </label>-->
<!--                            <div class="am-u-sm-9 am-u-end">-->
<!--                                <div class="x-region-select" data-region-selected>-->
<!--                                    <select name="agent[province_id]" data-province required>-->
<!--                                        <option value="">请选择省份</option>-->
<!--                                    </select>-->
<!--                                    <select name="agent[city_id]" data-city required>-->
<!--                                        <option value="">请选择城市</option>-->
<!--                                    </select>-->
<!--                                    <select name="agent[region_id]" data-region required>-->
<!--                                        <option value="">请选择地区</option>-->
<!--                                    </select>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->

                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">店铺详细地址</label>
                            <div class="am-u-sm-9 am-u-end">
                                <input type="text" class="tpl-form-input" name="agent[shop_name]" value="<?= $model['shop']['address']?>"
                                       required>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">客服电话</label>
                            <div class="am-u-sm-9 am-u-end">
                                <input type="text" class="tpl-form-input" name="agent[phone]" value="<?= $model['shop']['phone'] ?>"
                                       required>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">头像照片 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                            <div class="file-item">
                                                <a href="<?= getImage($model['shop']['logo_image_id']) ?>"
                                                   title="点击查看大图" target="_blank">
                                                    <img src="<?= getImage($model['shop']['logo_image_id']) ?>">
                                                </a>

                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">营业执照 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                            <div class="file-item">
                                                <a href="<?= getImage($model['shop']['image_id_yyzz']) ?>"
                                                   title="点击查看大图" target="_blank">
                                                    <img src="<?= getImage($model['shop']['image_id_yyzz']) ?>">
                                                </a>

                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">门头照片 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                            <div class="file-item">
                                                <a href="<?= getImage($model['shop']['image_id_mtz']) ?>"
                                                   title="点击查看大图" target="_blank">
                                                    <img src="<?= getImage($model['shop']['image_id_mtz']) ?>">
                                                </a>

                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">店内照片 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                            <div class="file-item">
                                                <a href="<?= getImage($model['shop']['image_id_dn']) ?>"
                                                   title="点击查看大图" target="_blank">
                                                    <img src="<?= getImage($model['shop']['image_id_dn']) ?>">
                                                </a>

                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">公户照片 </label>
                            <div class="am-u-sm-9 am-u-end">
                                <div class="am-form-file">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">

                                            <div class="file-item">
                                                <a href="<?= getImage($model['shop']['image_id_gh']) ?>"
                                                   title="点击查看大图" target="_blank">
                                                    <img src="<?= getImage($model['shop']['image_id_gh']) ?>">
                                                </a>

                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- 图片文件列表模板 -->
<script id="tpl-file-item" type="text/template">
    {{ each list }}
    <div class="file-item">
        <a href="{{ $value.file_path }}" title="点击查看大图" target="_blank">
            <img src="{{ $value.file_path }}">
        </a>
        <input type="hidden" name="{{ name }}" value="{{ $value.file_id }}">
        <i class="iconfont icon-shanchu file-item-delete"></i>
    </div>
    {{ /each }}
</script>
<!-- 文件库弹窗 -->
{{include file="layouts/_template/file_library" /}}

<script src="assets/common/plugins/umeditor/umeditor.config.js?v=<?= $version ?>"></script>
<script src="assets/common/plugins/umeditor/umeditor.min.js"></script>
<script src="assets/store/js/select.region.js?v=1.2"></script>


<script>
    var methods = {
        addItem: function ($ele, data) {
            var selectedId = $ele.data('id')
                , isSelected = false;
            $.each(data, function (i, item) {
                if (isSelected === false) {
                    isSelected === false && (isSelected = selectedId > 0 && selectedId === item.id);
                }
                var optionStr = '<option value="' + item.id + '">' + item.name + '</option>';
                $ele.append(optionStr);
            });
            isSelected && $ele.val(selectedId);

            $ele.change();
        },
        clearItem: function ($ele) {
            $ele.find('option').remove();
        }
    };

    //注册分类选择事件
    $('[data-fenlei-selected]').each(function () {
        var $doms = $(this);
        var $industry1 = $doms.find('[data-industry1]')
            , $industry2 = $doms.find('[data-industry2]');
        //选择一级分类列表
        $industry1.on("change", function () {
            var industry1Id = $(this).val();
            if (industry1Id > 0) {
                methods.clearItem($industry2);
                //methods.clearItem($region);
                $industry2.data('industry1Id', industry1Id);
                //遍历二级分类列表
                //console.log(INDUSTRY[0]);
                methods.addItem($industry2, INDUSTRY[0]['tree']);
            }
        });
        // 遍历一级分类列表
        methods.addItem($industry1, INDUSTRY);
    });

    $(function () {
        //选择营业执照图片
        $('.upload-fileyyzz').selectImages({
            name: 'agent[image_id_yyzz]'
        });
        //选择门头图片
        $('.upload-filemtz').selectImages({
            name: 'agent[image_id_mtz]'
        });
        //选择店内图片
        $('.upload-filedn').selectImages({
            name: 'agent[image_id_dn]'
        });
        //选择公户图片
        $('.upload-filegh').selectImages({
            name: 'agent[image_id_gh]'
        });
        $('.upload-fileface').selectImages({
            name: 'agent[id_img_face_id]'
        });
        //选择门头图片
        $('.upload-fileback').selectImages({
            name: 'agent[id_img_back_id]'
        });
        //选择店内图片
        $('.upload-filetx').selectImages({
            name: 'agent[head_img_id]'
        });
        // 富文本编辑器
        UM.getEditor('container', {
            initialFrameWidth: 375 + 15,
            initialFrameHeight: 600
        });
        /**
         * 表单验证提交
         * @type {*}
         */
        $('#my-form').superForm();

    });
</script>

